package gui.selectteam;

import javax.swing.table.DefaultTableModel;

import commondata.ITeam;
import commondata.NbaPool;

/**
 * The Class SelectTeamTableModel.
 */
public class SelectTeamTableModel extends DefaultTableModel {

	/**
	 * 
	 */
	private static final long serialVersionUID = -3184079659631400959L;

	/** The Constant COLUMN_COUNT. */
	public static final int COLUMN_COUNT = 6;


	/**
	 * Instantiates a new select team table model.
	 */
	public SelectTeamTableModel() {
		super();
	}

	/*
	 * (non-Javadoc)
	 * 
	 * @see javax.swing.table.TableModel#getColumnCount()
	 */
	public int getColumnCount() {

		return COLUMN_COUNT;
	}

	/*
	 * (non-Javadoc)
	 * 
	 * @see javax.swing.table.TableModel#getRowCount()
	 */
	public int getRowCount() {

		return NbaPool.getInstance().getNbaTeams().size() / COLUMN_COUNT * 2;
	}

	/*
	 * (non-Javadoc)
	 * 
	 * @see javax.swing.table.TableModel#getValueAt(int, int)
	 */
	public Object getValueAt(int row, int col) {

		int index = COLUMN_COUNT / 2 * row + col / 2;
		if (col % 2 == 0) {
			return super.getValueAt(row, col); //buttonMap.get(index);
		} else {
			ITeam team = NbaPool.getInstance().getNbaTeams().get(index);
			return team.getTeamName();
		}
	}

	/*
	 * (non-Javadoc)
	 * 
	 * @see javax.swing.table.AbstractTableModel#isCellEditable(int, int)
	 */
	@Override
	public boolean isCellEditable(int row, int col) {

		return col % 2 == 0;
	}

	/*
	 * (non-Javadoc)
	 * 
	 * @see javax.swing.table.AbstractTableModel#getColumnName(int)
	 */
	@Override
	public String getColumnName(int column) {

		if (column % 2 == 0) {
			return "LOGO";
		}
		return "NAME";
	}
}
